#bmi值测试人体体脂:

# class Bmi:
#
#     def __init__(self, name, weight, height):
#
#         self.name = name
#         self.weight = weight
#         self.height = height
#
#     def bmi(self):
#         return self.weight / self.height**2
#
# tb = Bmi('太白',80, 1.75)
# print(tb.bmi())

# 我们要让bmi方法伪装成属性,虽然在代码级别没有提升,但是看起来更合理.

# class Bmi:
#
#     def __init__(self, name, weight, height):
#
#         self.name = name
#         self.weight = weight
#         self.height = height
#
#     @property
#     def bmi(self):
#         return self.weight / self.height**2
#
# tb = Bmi('太白',80, 1.75)
# print(tb.bmi)
# print(tb.weight)




class Foo:

    def __init__(self,name):
        self.name = name
    @property
    def aaa(self):
        print('get的时候运行我啊')

    @aaa.setter
    def aaa(self,v):
        print('修改的时候执行我')

    @aaa.deleter
    def aaa(self):
        print('删除的时候执行我')
obj = Foo('alex')
# print(obj.name)
# obj.name = 'dsb'
# del obj.name
# print(obj.name)
# obj.aaa
# obj.aaa = '太白'
# print(Foo.aaa)
# del obj.aaa

# 设置属性的另外一种写法:


# class Foo:
#
#     def get_AAA(self):
#         print('get的时候运行我啊')
#
#     def set_AAA(self,value):
#         print('set的时候运行我啊')
#
#     def delete_AAA(self):
#         print('delete的时候运行我啊')
#
#
#     bbb = property(get_AAA,set_AAA,delete_AAA) #内置property三个参数与get,set,delete一一对应
#
# f1=Foo()
# f1.bbb
# f1.bbb='aaa'
# del f1.bbb
